package com.da.javatest.leetCode;

import java.util.Arrays;

/**
 * @author chenlida
 * @date 2019/2/27 15:16
 * @description
 */
public class Code813 {
    public double largestSumOfAverages(int[] A, int K) {
        double r = 0, sum = 0;
        int count = 0;
        Arrays.sort(A);
        for (int i = A.length - 1; i >= 0; i--) {
            if (K == 1) {
                sum += A[i];
                count++;
            } else {
                r += A[i];
                K--;
            }
        }
        r += (sum / count);
        return r;
    }
}
